package io.tim.application.judge.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import io.tim.application.judge.form.LoginJudgeForm;
import io.tim.application.judge.service.LoginJudgeService;
import io.tim.application.judge.service.LoginJudgeServiceImpl;
import io.tim.mvc.action.Action;
import io.tim.mvc.form.ActionForm;
import io.tim.mvc.service.vo.ResultVO;

/**
 * 作为一个具体业务的 Action 类，实现 Action 接口及其 execute 方法
 * 
 * @author Zhang Nan
 * @since 2017/02/21
 *
 */

public class LoginJudgeAction implements Action {

	/**
	 * 重载接口的 execute 方法，调用对应业务的服务实现类执行具体的业务处理流程
	 * 
	 * @param request
	 *            -- 通过 HttpServletRequest 获得显示端输入的内容传递给
	 *            业务处理流程的服务类，处理完毕后获得结果传递给显示端去做显示处理
	 * 
	 * @param form
	 *            -- 对应的业务 bean
	 * 
	 * @param actionForward
	 *            -- 业务处理后的反馈操作跳转
	 */
	@Override
	public String execute(HttpServletRequest request, ActionForm form, Map<String, String> actionForward) {
		/*
		 * String inputUserName = request.getParameter("username"); String
		 * inputPassword = request.getParameter("password");
		 */
		String dispatchUrl = "";

		LoginJudgeService service = new LoginJudgeServiceImpl();
		ResultVO resultVO = service.getVO(request, (LoginJudgeForm) form, actionForward);
		dispatchUrl = resultVO.getDispatchUrl();
		request.setAttribute("message", resultVO.getMessageVo());
		System.out.println("ResultVO: " + resultVO);
		return dispatchUrl;
	}

}
